aboutsummaryrefslogtreecommitdiff
path: root/src/app/kdrama/[id]/page.jsx
blob: 38593e70c33fd9e635f0a42208a539fc96c06d9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import styles from "../styles/info.module.css";
import Image from "next/image";
import EpisodesButtons from "./buttons";
import { PreFetchVideoLinks } from "../components/cacher";

export const runtime = "edge";

export default async function DramaInfo({ params }) {
	const id = decodeURIComponent(params.id);
	const info = await getDramaInfo(id);

	PreFetchVideoLinks(info.episodes, id);

	return (
		<div className={styles.Main}>
			{info && (
				<div className={styles.DramaInfoContainer}>
					<div className={styles.TitleContainer}>
						<p>{info.title}</p>
						<Image
							src={`https://sup-proxy.zephex0-f6c.workers.dev/api-content?url=${info.image}`}
							width={175}
							height={256}
							alt="Drama Poster"
							priority
						/>
					</div>

					{/* Drama description */}
					<div className={styles.DramaDescription}>
						<h2>Description</h2>
						<p>{info.description}</p>
					</div>

					{/* Genres */}
					<div className={styles.DramaGenre}>
						<span className={styles.genreMain}>Genres: </span>
						{info.genres &&
							info.genres.map((item, index) => (
								<p key={index}>{item}</p>
							))}
					</div>

					{/* Other names */}
					<div className={styles.DramaGenre}>
						<span className={styles.genreMain}>AKA: </span>
						{info.otherNames &&
							info.otherNames.map((item, index) => (
								<p key={index}>{item}</p>
							))}
					</div>

					{/* Episodes Buttons */}
					<EpisodesButtons data={info.episodes} id={id} />
				</div>
			)}
		</div>
	);
}

async function getDramaInfo(id) {
	const res = await fetch(
		`https://consumet-jade.vercel.app/movies/dramacool/info?id=${id}`,
		{ next: { revalidate: 21600 } }
	);
	const data = await res.json();
	return data;
}